#include "arguments.h"
#include "string_util.h"
#include <iostream>

namespace krryn{
namespace core{
	std::map<std::string, std::string> arguments::m_Args;

	void arguments::init(int argc, char **argv){
		// skip application startup path
		for(int i = 1; i < argc; i++){
			if(starts_with(argv[i], "--")){
				std::string stripped = ltrim(argv[i], '-');

				std::string::size_type l_Position = stripped.find_first_of('=');

				m_Args[stripped.substr(0, l_Position)] = stripped.substr(l_Position + 1);
			}
		}
	}

	bool arguments::has(const std::string &a_Name){
		return m_Args.find(a_Name) != m_Args.end();
	}

	std::string arguments::get(const std::string &a_Name){
		return m_Args[a_Name];
	}
}
}